{
 "metadata": {
  "name": "01-IntroPython"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Introducci\u00f3n a python y al notebook de IPython"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Usando el notebook como una calculadora"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "1+3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "math.cos(pi)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "### Por que sale un solo resultado?\n",
      "math.sin(pi)\n",
      "math.tan(3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "a=math.sqrt(2)\n",
      "b=a**2\n",
      "print b"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Variables y tipos num\u00e9ricos"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "a=3\n",
      "b=9.5\n",
      "c=True\n",
      "d=1+3.j"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print a,b,c,d"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Condicionales en python"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "a=3\n",
      "b=5\n",
      "\n",
      "if a>b:\n",
      "    print \"{} es mayor a {}\".format(a,b)\n",
      "else:\n",
      "    print \"{} no es mayor a {}\".format(a,b)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ciclos \"while\" en python"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "a=0\n",
      "while a<10:\n",
      "    print a\n",
      "    a+=1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Listas y tuplas en python"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Creando una lista\n",
      "l=[1,2,3,4,5,6,7,8,9]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#sacando datos de una lista\n",
      "print l[1]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print l[0:4]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Cambiando datos de una lista\n",
      "l[3]=\"tres\"\n",
      "print l"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Funci\u00f3n range\n",
      "\n",
      "print range(10)\n",
      "print range(2,10)\n",
      "print range(2,10,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ciclos \"for\" en python"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "for i in range(10):\n",
      "    print i,"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "l=[1,2,4,3,5,6,7,\"tres\",\"cinco\"]\n",
      "for i in l:\n",
      "    print i,"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Tuplas\n",
      "t=(1,2,3,4,5)\n",
      "print t"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "for i in t:\n",
      "    print i,"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "t[0]=5"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Funciones en python"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def func(x,y):\n",
      "    a=0\n",
      "    for i in range(x):\n",
      "        a=a+float(i)/y\n",
      "    return a"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "func(7,5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Pidiendo ayuda"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "range?"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ejercicios de programaci\u00f3n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "1. Hacer y probar una funci\u00f3n que reciba un parametro n e imprima los numeros pares menores a n\n",
      "1. Hacer una funci\u00f3n que verifique si un numero es primo, y con esta escribir un c\u00f3digo que indique cuantos n\u00fameros hay menores a 100"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}